import java.util.HashSet;
import java.util.Set;

/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-04-11
 * Time:12:44
 */
public class 唯一摩尔斯密码词 {

    public static final String[] MORSE = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.",
            "....", "..", ".---", "-.-", ".-..", "--", "-.",
            "---", ".--.", "--.-", ".-.", "...", "-", "..-",
            "...-", ".--", "-..-", "-.--", "--.."};

    public int uniqueMorseRepresentations(String[] words) {
        Set<String> set = new HashSet<String>();
        for (String word:words) {
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < word.length(); i++) {
                char ch = word.charAt(i);
                stringBuilder.append(MORSE[ch - 'a']);
            }
            set.add(stringBuilder.toString());
        }
        return set.size();
    }
}
